package org.supda.system.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * TRole entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_role", catalog = "comsys")
public class TRole implements java.io.Serializable {

	// Fields

	private Long id;
	private Short locked;
	private String name;
	private String roleKey;
	private String description;
	private Short valid;
	private Set<TResources> TResourceses = new HashSet<TResources>(0);
	private Set<TUser> TUsers = new HashSet<TUser>(0);

	// Constructors

	/** default constructor */
	public TRole() {
	}

	/** minimal constructor */
	public TRole(Short valid) {
		this.valid = valid;
	}

	/** full constructor */
	public TRole(Short locked, String name, String roleKey, String description,
			Short valid, Set<TResources> TResourceses, Set<TUser> TUsers) {
		this.locked = locked;
		this.name = name;
		this.roleKey = roleKey;
		this.description = description;
		this.valid = valid;
		this.TResourceses = TResourceses;
		this.TUsers = TUsers;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "name", length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "roleKey", length = 50)
	public String getRoleKey() {
		return this.roleKey;
	}

	public void setRoleKey(String roleKey) {
		this.roleKey = roleKey;
	}

	@Column(name = "description", length = 50)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "valid", nullable = false)
	public Short getValid() {
		return this.valid;
	}

	public void setValid(Short valid) {
		this.valid = valid;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "t_res_role", catalog = "comsys", joinColumns = { @JoinColumn(name = "roleId", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "resId", nullable = false, updatable = false) })
	public Set<TResources> getTResourceses() {
		return this.TResourceses;
	}

	public void setTResourceses(Set<TResources> TResourceses) {
		this.TResourceses = TResourceses;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TRoles")
	public Set<TUser> getTUsers() {
		return this.TUsers;
	}

	public void setTUsers(Set<TUser> TUsers) {
		this.TUsers = TUsers;
	}

	@Column(name = "locked", nullable = false)
	public Short getLocked() {
		return locked;
	}

	public void setLocked(Short locked) {
		this.locked = locked;
	}

}